#!/usr/bin/perl -w
# Convert a tab-delimited data file to Javascript text
# defining a single object variable with an array property for each column.
# Usage: delim_to_js.pl object_name < input.txt > output.js
if ($#ARGV < 0) {
    print 'Syntax: ', $0, ' object_name < input.txt > output.js', "\n";
} else {
my $objName = $ARGV[0];
my @columns = split /\t/, <STDIN>;
my @rows = <STDIN>;
print 'var ', $objName, ' = {"', $columns[0], '":[', "\n";
foreach (@rows) {
    chomp;
    my @values = split;
    print '"', $values[0], '",';
}

}
